home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWMenu / Sources / FWMnuBar.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  18.7 KB  |  576 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWMnuBar.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWMNUBAR_H
  13. #include "FWMnuBar.h"
  14. #endif
  15.  
  16. #ifndef FWPULLDM_H
  17. #include "FWPullDM.h"
  18. #endif
  19.  
  20. // ----- Foundation Includes -----
  21.  
  22. #ifndef FWSTRS_H
  23. #include "FWStrs.h"
  24. #endif
  25.  
  26. // ----- OS Includes -----
  27.  
  28. #ifndef FWRESOUR_H
  29. #include "FWResour.h"
  30. #endif
  31.  
  32. #ifndef FWMENU_K
  33. #include "FWMenu.k"
  34. #endif
  35.  
  36. // ----- ODUtil Includes -----
  37.  
  38. #ifndef FWORDCOL_H
  39. #include "FWOrdCol.h"
  40. #endif
  41.  
  42. // ----- OpenDoc Includes -----
  43.  
  44. #ifndef SOM_ODPart_xh
  45. #include <Part.xh>
  46. #endif
  47.  
  48. #ifndef SOM_ODDraft_xh
  49. #include <Draft.xh>
  50. #endif
  51.  
  52. #ifndef SOM_ODStorageUnit_xh
  53. #include <StorageU.xh>
  54. #endif
  55.  
  56. #ifndef SOM_ODSession_xh
  57. #include <ODSessn.xh>
  58. #endif
  59.  
  60. #ifndef SOM_ODWindowState_xh
  61. #include <WinStat.xh>
  62. #endif
  63.  
  64. // ----- Macintosh Includes -----
  65.  
  66. #if defined(FW_BUILD_MAC) && !defined(__TOOLUTILS__)
  67. #include <ToolUtils.h>
  68. #endif
  69.  
  70. #if defined(__MWERKS__) && GENERATING68K
  71. // A hack to work around a bug
  72. #pragma import list somGetGlobalEnvironment
  73. #endif
  74.  
  75. //========================================================================================
  76. //    RunTime Info
  77. //========================================================================================
  78.  
  79. #ifdef FW_BUILD_MAC
  80. #pragma segment fwmenu
  81. #endif
  82.  
  83. //========================================================================================
  84. //    class FW_CMenuBar
  85. //========================================================================================
  86.  
  87. //----------------------------------------------------------------------------------------
  88. //    FW_CMenuBar::FW_CMenuBar
  89. //----------------------------------------------------------------------------------------
  90.  
  91. FW_CMenuBar::FW_CMenuBar(Environment* ev, ODPart* thePart, FW_Instance partInstance) :
  92.     fODPart(thePart),
  93.     fPullDownMenuList(NULL),
  94.     fNextMenuID(FW_kFirstMenuID),
  95.     fPartInstance(partInstance)
  96. {
  97.     fODMenuBar = fODPart->GetStorageUnit(ev)->GetSession(ev)->GetWindowState(ev)->CopyBaseMenuBar(ev);
  98.     fPullDownMenuList = FW_NEW(FW_TOrderedCollection<FW_CPullDownMenu>, ());
  99. }
  100.  
  101. //----------------------------------------------------------------------------------------
  102. //    FW_CMenuBar::InitializeFromResource
  103. //----------------------------------------------------------------------------------------
  104.  
  105. void FW_CMenuBar::InitializeFromResource(Environment* ev, FW_ResourceId menuBarResourceID)
  106. {
  107.     // InitializeFromResource should only be called once, immediately after
  108.     // the menu bar is created, while the menu list is still empty.
  109.     // However, since it simply appends the menus to the end of the menubar,
  110.     // there may be no harm in calling it more than once.
  111.     // FW_ASSERT(fPullDownMenuList->Count() == 0);
  112.  
  113.     FW_TRY
  114.     {
  115.         FW_CSharedLibraryResourceFile resFile(ev, fPartInstance);
  116.         FW_PResource menuBarResource(ev, resFile, menuBarResourceID, FW_kMenuBarResourceType);
  117.         FW_PResourceSink sink(ev, menuBarResource);
  118.         FW_CReadableStream stream(sink);
  119.         InitializeFromStream(ev, stream);
  120.     }
  121.     FW_CATCH_BEGIN
  122.     FW_CATCH_REFERENCE(FW_XException, except)
  123.     {
  124.         // We use this try-catch block purely to warn about a common mistake.
  125.         // If one forgets to add the resource containing their menus to their project,
  126.         // or passes in the wrong menu id, the above code will throw an exception
  127.         // that probably won't get caught until the SOM entry point from OpenDoc.
  128.         // OpenDoc will display an error dialog that isn't particularly helpful
  129.         // in diagnosing the problem.
  130.         FW_DEBUG_MESSAGE("Failed to load menu resource.");
  131.         FW_PlatformError error = except.GetPlatformError();
  132.         FW_THROW_SAME();
  133.     }
  134.     FW_CATCH_END
  135. }
  136.  
  137. //----------------------------------------------------------------------------------------
  138. //    FW_CMenuBar::InitializeFromStream
  139. //----------------------------------------------------------------------------------------
  140.  
  141. void FW_CMenuBar::InitializeFromStream(Environment* ev, FW_CReadableStream& stream)
  142. {
  143.     // InitializeFromStream should only be called once, immediately after
  144.     // the menu bar is created, while the menu list is still empty.
  145.     // However, since it simply appends the menus to the end of the menubar,
  146.     // there may be no harm in calling it more than once.
  147.     // FW_ASSERT(fPullDownMenuList->Count() == 0);
  148.  
  149.     // This first FW_DO_NOT_DEAD_STRIP is a must, so it makes full sense to have it here.
  150.     FW_DO_NOT_DEAD_STRIP(FW_CPullDownMenu);
  151.     
  152.     // These aren't absolutely required, but it would be extremely rare to have menu
  153.     // items without Text and Separators, so for convenience we prevent them from
  154.     // being dead stripped in any part that initializes it's menus from a stream (resource).
  155.     // However, the other kinds of menu items must be explicitly prevented from being
  156.     // deadstripped in every part that uses them.
  157.     FW_DO_NOT_DEAD_STRIP(FW_CTextItem);
  158.     FW_DO_NOT_DEAD_STRIP(FW_CSeparatorItem);
  159.  
  160.     short nMenus;
  161.     stream >> nMenus;
  162.     
  163.     while (nMenus-- > 0)
  164.     {
  165.         FW_CPullDownMenu* pullDownMenu;
  166.         FW_READ_DYNAMIC_OBJECT(stream, &pullDownMenu, FW_CPullDownMenu);
  167.         FW_ASSERT(pullDownMenu != 0);
  168.         AdoptMenuLast(ev, pullDownMenu);
  169.     }
  170. }
  171.  
  172. //----------------------------------------------------------------------------------------
  173. //    FW_CMenuBar::~FW_CMenuBar
  174. //----------------------------------------------------------------------------------------
  175.  
  176. FW_CMenuBar::~FW_CMenuBar()
  177. {
  178.     Environment* ev = somGetGlobalEnvironment();
  179.     
  180.     if (fPullDownMenuList)
  181.         DeleteAll(ev);
  182.  
  183.     if (fODMenuBar)
  184.         fODMenuBar->Release(ev);
  185. }
  186.  
  187. //----------------------------------------------------------------------------------------
  188. //    FW_CMenuBar::AdoptMenuFirst
  189. //----------------------------------------------------------------------------------------
  190.  
  191. void FW_CMenuBar::AdoptMenuFirst(Environment* ev, FW_CPullDownMenu* menu)
  192. {
  193.     FW_ASSERT(menu != NULL);
  194.     FW_ASSERT(PrivFindMenuWithID(ev, menu->GetMenuID(ev)) == NULL);     // Test that the menuID is not already used
  195.     
  196.     FW_CPullDownMenu* first = (FW_CPullDownMenu*)fPullDownMenuList->First();
  197.     fPullDownMenuList->AddFirst(menu);
  198.     
  199.     ODMenuID beforeID = first == NULL ? -1 : first->GetMenuID(ev);    
  200.     menu->PrivAttachedToMenuBar(ev, fODPart, this, beforeID);
  201. }
  202.  
  203. //----------------------------------------------------------------------------------------
  204. //    FW_CMenuBar::AdoptMenuLast
  205. //----------------------------------------------------------------------------------------
  206.  
  207. void FW_CMenuBar::AdoptMenuLast(Environment* ev, FW_CPullDownMenu* menu)
  208. {
  209.     FW_ASSERT(menu != NULL);
  210.     FW_ASSERT(PrivFindMenuWithID(ev, menu->GetMenuID(ev)) == NULL);    // Test that the menuID is not already used
  211.     
  212.     fPullDownMenuList->AddLast(menu);    
  213.     menu->PrivAttachedToMenuBar(ev, fODPart, this, -1);
  214. }
  215.  
  216. //----------------------------------------------------------------------------------------
  217. //    FW_CMenuBar::AdoptMenuBefore
  218. //----------------------------------------------------------------------------------------
  219.  
  220. void FW_CMenuBar::AdoptMenuBefore(Environment* ev, FW_CPullDownMenu* menu, FW_CPullDownMenu* beforeMenu)
  221. {
  222.     FW_ASSERT(menu != NULL);
  223.     FW_ASSERT(PrivFindMenuWithID(ev, menu->GetMenuID(ev)) == NULL);    // Test that the menuID is not already used
  224.  
  225.     if (beforeMenu == NULL)
  226.         AdoptMenuFirst(ev, menu);
  227.     else
  228.     {
  229.         fPullDownMenuList->AddBefore(beforeMenu, menu);
  230.         menu->PrivAttachedToMenuBar(ev, fODPart, this, beforeMenu->GetMenuID(ev));
  231.     }
  232. }
  233.  
  234. //----------------------------------------------------------------------------------------
  235. //    FW_CMenuBar::AdoptMenuAfter
  236. //----------------------------------------------------------------------------------------
  237.  
  238. void FW_CMenuBar::AdoptMenuAfter(Environment* ev, FW_CPullDownMenu* menu, FW_CPullDownMenu* afterMenu)
  239. {
  240.     FW_ASSERT(menu != NULL);
  241.     FW_ASSERT(PrivFindMenuWithID(ev, menu->GetMenuID(ev)) == NULL);    // Test that the menuID is not already used
  242.  
  243.     if (afterMenu == NULL)
  244.         AdoptMenuLast(ev, menu);
  245.     else
  246.     {
  247.         FW_CPullDownMenu* next = (FW_CPullDownMenu*)fPullDownMenuList->After(afterMenu);
  248.         fPullDownMenuList->AddAfter(afterMenu, menu);
  249.         ODMenuID beforeID = next == NULL ? -1 : next->GetMenuID(ev);    
  250.         menu->PrivAttachedToMenuBar(ev, fODPart, this, beforeID);
  251.     }
  252. }
  253.  
  254. //----------------------------------------------------------------------------------------
  255. //    FW_CMenuBar::DeleteMenu
  256. //----------------------------------------------------------------------------------------
  257.  
  258. void FW_CMenuBar::DeleteMenu(Environment* ev, FW_CPullDownMenu* menuToDelete)
  259. {
  260.     FW_ASSERT(menuToDelete != NULL);
  261.  
  262.     DetachMenu(ev, menuToDelete);
  263.     delete menuToDelete;
  264. }
  265.  
  266. //----------------------------------------------------------------------------------------
  267. //    FW_CMenuBar::DeleteAll
  268. //----------------------------------------------------------------------------------------
  269.  
  270. void FW_CMenuBar::DeleteAll(Environment* ev)
  271. {
  272.     FW_CPullDownMenu *menu;
  273.     while ((menu = fPullDownMenuList->First()) != NULL)
  274.     {
  275.         DeleteMenu(ev, menu);
  276.     }
  277. }
  278.  
  279. //----------------------------------------------------------------------------------------
  280. //    FW_CMenuBar::RemoveItem
  281. //----------------------------------------------------------------------------------------
  282.  
  283. void FW_CMenuBar::RemoveItem(Environment* ev, ODCommandID commandID)
  284. {
  285.     FW_CMenuItem* item = this->GetMenuItemFromCommand(ev, commandID);
  286.     FW_ASSERT(item);
  287.     
  288.     FW_CPullDownMenu* menu = item->GetOwnerMenu(ev);
  289.     menu->RemoveItem(ev, item->GetIndex(ev));
  290. }
  291.  
  292. //----------------------------------------------------------------------------------------
  293. //    FW_CMenuBar::DetachMenu
  294. //----------------------------------------------------------------------------------------
  295.  
  296. void FW_CMenuBar::DetachMenu(Environment* ev, FW_CPullDownMenu* menuToDetach)
  297. {
  298.     FW_ASSERT(menuToDetach != NULL);
  299.     
  300.     fODMenuBar->RemoveMenu(ev, menuToDetach->GetMenuID(ev));
  301.     
  302.     fPullDownMenuList->Remove(menuToDetach);
  303.     menuToDetach->PrivDetachedFromMenuBar(ev, this);
  304. }
  305.  
  306. //----------------------------------------------------------------------------------------
  307. //    FW_CMenuBar::GetMenuKey
  308. //----------------------------------------------------------------------------------------
  309.  
  310. FW_MenuKey FW_CMenuBar::GetMenuKey(Environment* ev, ODCommandID cmdNumber) const
  311. {
  312. #ifdef FW_BUILD_MAC
  313.     FW_MenuKey menuKey;
  314.     
  315.     ODMenuID menuID;
  316.     ODMenuItemID menuItem;
  317.     fODMenuBar->GetMenuAndItem(ev, cmdNumber, &menuID, &menuItem);
  318.     
  319.     ::GetItemCmd(GetMenuHandle(menuID), menuItem, &menuKey);
  320.     return menuKey;
  321. #endif
  322.  
  323. #ifdef FW_BUILD_WIN
  324.     return 0;                    // [HLX] no way yet to parse accelerator table
  325. #endif
  326. }
  327.  
  328. //----------------------------------------------------------------------------------------
  329. //    FW_CMenuBar::AcquireODMenuBar
  330. //----------------------------------------------------------------------------------------
  331.  
  332. ODMenuBar* FW_CMenuBar::AcquireODMenuBar(Environment* ev) const
  333. {
  334. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  335.     fODMenuBar->Acquire(ev);
  336. #else
  337.     fODMenuBar->IncrementRefCount(ev);
  338. #endif
  339.     return fODMenuBar;
  340. }
  341.  
  342. //----------------------------------------------------------------------------------------
  343. //    FW_CMenuBar::PrivFindMenuWithID
  344. //----------------------------------------------------------------------------------------
  345.  
  346. FW_CPullDownMenu* FW_CMenuBar::PrivFindMenuWithID(Environment* ev, ODMenuID menuID) const
  347. {
  348.     // ----- Look the top level first -----
  349.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  350.     FW_CPullDownMenu* pullDownMenu;
  351.     for (pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  352.     {
  353.         if (pullDownMenu->GetMenuID(ev) == menuID)
  354.             return pullDownMenu;
  355.     }
  356.     
  357.     // ----- Then Look sub menus -----
  358.     for (pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  359.     {
  360.         FW_CPullDownMenu* menu = pullDownMenu->PrivFindMenuWithID(ev, menuID);
  361.         if (menu)
  362.             return menu;
  363.     }
  364.     
  365.     return NULL;
  366. }
  367.  
  368. #ifdef FW_BUILD_MAC
  369. //----------------------------------------------------------------------------------------
  370. //    FW_CMenuBar::MacEnableMenuBar
  371. //----------------------------------------------------------------------------------------
  372. //    This is specific for modal dialogs on the mac
  373.  
  374. void FW_CMenuBar::MacEnableMenuBar(Environment* ev, FW_Boolean enable)
  375. {
  376.     // ----- Apple & OpenDoc Menus -----
  377.     fODMenuBar->EnableCommand(ev, kODCommandAppleMenu, enable);
  378.     fODMenuBar->EnableCommand(ev, kODCommandEditMenu, enable);
  379.     fODMenuBar->EnableCommand(ev, kODCommandDocumentMenu, enable);
  380.  
  381.     // ----- Then custom menus -----
  382.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  383.     for (FW_CPullDownMenu* pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  384.     {
  385.         if (enable)
  386.             ::EnableItem(GetMenuHandle(pullDownMenu->GetMenuID(ev)), 0);
  387.         else
  388.             ::DisableItem(GetMenuHandle(pullDownMenu->GetMenuID(ev)), 0);
  389.     }
  390.     
  391.     ::InvalMenuBar();
  392. }
  393. #endif
  394.  
  395. //----------------------------------------------------------------------------------------
  396. //    FW_CMenuBar::EnableCommand
  397. //----------------------------------------------------------------------------------------
  398.  
  399. void FW_CMenuBar::EnableCommand(Environment* ev, ODCommandID cmdNumber, FW_Boolean enable)
  400. {
  401.     fODMenuBar->EnableCommand(ev, cmdNumber, enable);
  402.  
  403. #ifdef FW_BUILD_MAC
  404.     PrivMacEnableParentItem(ev, cmdNumber);
  405. #endif
  406. }
  407.  
  408. #ifdef FW_BUILD_MAC
  409. //----------------------------------------------------------------------------------------
  410. //    FW_CMenuBar::PrivMacEnableParentItem
  411. //----------------------------------------------------------------------------------------
  412.  
  413. void FW_CMenuBar::PrivMacEnableParentItem(Environment* ev, ODCommandID cmdNumber)
  414. {
  415.     ODMenuID menuID;
  416.     ODMenuItemID menuItem;
  417.     
  418.     fODMenuBar->GetMenuAndItem(ev, cmdNumber, &menuID, &menuItem);
  419.     
  420.     FW_CPullDownMenu* menu = this->PrivFindMenuWithID(ev, menuID);
  421.     if (menu == NULL)
  422.         return;
  423.         
  424.     FW_CMenuItem *parentItem = menu->GetParentMenuItem(ev);
  425.     if (parentItem == NULL)
  426.         return;
  427.         
  428.     ODPlatformMenu platformMenu = menu->GetPlatformMenu(ev);
  429.     long flags = (*platformMenu)->enableFlags;
  430.     
  431.     if ((flags & 0xFFFFFFFE) != 0)            // if any items enabled
  432.         flags |= 0x00000001;                // Enabled top level item
  433.     else
  434.         flags &= 0x11111110;                // Disabled top level item
  435.     
  436.     if ((flags & 0x00000001) != ((*platformMenu)->enableFlags & 0x00000001))
  437.     {
  438.         (*platformMenu)->enableFlags = flags;
  439.     }
  440.     
  441.     ODPlatformMenu parentMenu = parentItem->GetOwnerMenu(ev)->GetPlatformMenu(ev);
  442.     if ((flags & 0xFFFFFFFE) != 0)    // if any items enabled
  443.         ::EnableItem(parentMenu, parentItem->GetIndex(ev));
  444.     else
  445.         ::DisableItem(parentMenu, parentItem->GetIndex(ev));
  446. }
  447. #endif
  448.  
  449. //----------------------------------------------------------------------------------------
  450. //    FW_CMenuBar::GetMenuItemFromCommand
  451. //----------------------------------------------------------------------------------------
  452.  
  453. FW_CMenuItem* FW_CMenuBar::GetMenuItemFromCommand(Environment* ev, ODCommandID cmdNumber) const
  454. {
  455.     // ----- Look the top level first -----
  456.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  457.     for (FW_CPullDownMenu* pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  458.     {
  459.         FW_CMenuItem* menuItem = pullDownMenu->PrivGetMenuItem(ev, cmdNumber);
  460.         if (menuItem != NULL)
  461.             return menuItem;
  462.     }    
  463.     return NULL;    
  464. /*
  465. #ifdef FW_BUILD_MAC
  466.     ODMenuID menuID;
  467.     ODMenuItemID menuItem;
  468.     
  469.     fODMenuBar->GetMenuAndItem(ev, cmdNumber, &menuID, &menuItem);
  470.     FW_CPullDownMenu* menu = this->PrivFindMenuWithID(ev, menuID);
  471.     if (menu == NULL)
  472.         return NULL;
  473.  
  474.     return menu->PrivGetMenuItem(ev, cmdNumber);
  475. #endif
  476. */
  477. }
  478.  
  479. //----------------------------------------------------------------------------------------
  480. //    FW_CMenuBar::ToggleItem
  481. //----------------------------------------------------------------------------------------
  482.  
  483. void FW_CMenuBar::ToggleItem(Environment* ev, 
  484.                             ODCommandID cmdNumber, 
  485.                             FW_Boolean toggleState)
  486. {
  487.     FW_CMenuItem* menuItem = GetMenuItemFromCommand(ev, cmdNumber);
  488.     FW_ASSERT(menuItem != NULL);
  489.     
  490. #ifdef FW_DEBUG
  491.     FW_CToggleItem* toggleItem = FW_DYNAMIC_CAST(FW_CToggleItem, menuItem);
  492.     FW_ASSERT(toggleItem);
  493.     toggleItem->ToggleItem(ev, toggleState);
  494. #else
  495.     ((FW_CToggleItem*)menuItem)->ToggleItem(ev, toggleState);
  496. #endif
  497. }
  498.  
  499. //----------------------------------------------------------------------------------------
  500. //    FW_CMenuBar::DisableAll
  501. //----------------------------------------------------------------------------------------
  502.  
  503. void FW_CMenuBar::DisableAll(Environment* ev)
  504. {
  505.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  506.     for (FW_CPullDownMenu* pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  507.     {
  508.         pullDownMenu->DisableAll(ev);
  509.     }    
  510. }
  511.  
  512. //----------------------------------------------------------------------------------------
  513. //    FW_CMenuBar::EnableAll
  514. //----------------------------------------------------------------------------------------
  515.  
  516. void FW_CMenuBar::EnableAll(Environment* ev)
  517. {
  518.     FW_TOrderedCollectionIterator<FW_CPullDownMenu> ite(fPullDownMenuList);
  519.     for (FW_CPullDownMenu* pullDownMenu = ite.First(); ite.IsNotComplete(); pullDownMenu = ite.Next())
  520.     {
  521.         pullDownMenu->EnableAll(ev);
  522.     }    
  523. }
  524.  
  525. //----------------------------------------------------------------------------------------
  526. //    FW_CMenuBar::CheckCommand
  527. //----------------------------------------------------------------------------------------
  528.  
  529. void FW_CMenuBar::CheckCommand(Environment* ev, ODCommandID cmdNumber, FW_Boolean check)
  530. {
  531.     fODMenuBar->CheckCommand(ev, cmdNumber, check);
  532. }
  533.  
  534. //----------------------------------------------------------------------------------------
  535. //    FW_CMenuBar::EnableAndCheckCommand
  536. //----------------------------------------------------------------------------------------
  537.  
  538. void FW_CMenuBar::EnableAndCheckCommand(Environment* ev, ODCommandID cmdNumber, FW_Boolean enable, FW_Boolean check)
  539. {
  540.     fODMenuBar->EnableAndCheckCommand(ev, cmdNumber, enable, check);
  541.  
  542. #ifdef FW_BUILD_MAC
  543.     PrivMacEnableParentItem(ev, cmdNumber);
  544. #endif
  545. }
  546.  
  547. //----------------------------------------------------------------------------------------
  548. //    FW_CMenuBar::EnableAndToggleCommand
  549. //----------------------------------------------------------------------------------------
  550.  
  551. void FW_CMenuBar::EnableAndToggleCommand(Environment* ev, ODCommandID cmdNumber, FW_Boolean enable, FW_Boolean toggleState)
  552. {
  553.     EnableCommand(ev, cmdNumber, enable);
  554.     ToggleItem(ev, cmdNumber, toggleState);
  555. }
  556.  
  557. //----------------------------------------------------------------------------------------
  558. //    FW_CMenuBar::SetItemString
  559. //----------------------------------------------------------------------------------------
  560.  
  561. void FW_CMenuBar::SetItemString(Environment* ev, ODCommandID commandID, const FW_CString& itemString)
  562. {
  563.     fODMenuBar->SetItemString(ev, commandID, itemString.RevealODIText());
  564. }
  565.  
  566. //----------------------------------------------------------------------------------------
  567. //    FW_CMenuBar::GetItemString
  568. //----------------------------------------------------------------------------------------
  569.  
  570. void FW_CMenuBar::GetItemString(Environment* ev, ODCommandID commandID, FW_CString& itemString) const
  571. {
  572.     ODIText intlText;
  573.     fODMenuBar->GetItemString(ev, commandID, &intlText);
  574.     itemString = &intlText;
  575. }
  576.